package com.chookss.home.audit.project;


import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.SimpleItemAnimator;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.target.SimpleTarget;
import com.bumptech.glide.request.transition.Transition;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.chookss.MyApp;
import com.chookss.R;
import com.chookss.Urls;
import com.chookss.base.BaseViewHolderEx;
import com.chookss.base.StaticClass;
import com.chookss.home.audit.shop.ShopDetailActivity;
import com.chookss.home.audit.shop.ShopProjecDeliveryActivity;
import com.chookss.home.audit.shop.ShopServiceActivity;
import com.chookss.home.audit.shop.ShopServiceRecordActivity;
import com.chookss.home.audit.shop.ShopStatusEditActivity;
import com.chookss.home.entity.ContactEntity;
import com.chookss.home.entity.ShopEntity;
import com.chookss.home.logContacts.ContactsLogChoiceActivity;
import com.chookss.tools.ClearMoreZeroUtil;
import com.chookss.tools.GlideUtils;
import com.chookss.tools.MyEvent;
import com.chookss.tools.MyToast;
import com.chookss.tools.SignUtils2;
import com.chookss.tools.Utils;
import com.chookss.tools.okgoconfig.MyHttpRequest;
import com.chookss.tools.okgoconfig.OkGoUtil;
import com.chookss.tools.okgoconfig.callback.JsonCallback;
import com.chookss.tools.okgoconfig.callback.ObserverCallback;
import com.chookss.tools.okgoconfig.model.LzyResponse;
import com.chookss.view.BottomListsDialog;
import com.chookss.view.RoundCornerImageView;
import com.chookss.view.SelectDialogListener;
import com.chookss.view.consecutivescroller.ConsecutiveScrollerLayout;
import com.chookss.wxapi.WeChatShareUtil;
import com.google.gson.reflect.TypeToken;
import com.johnrambo.ktea.base.LoadingFragment;
import com.johnrambo.ktea.ktExtends.ShareUtils;
import com.lzy.okgo.model.Response;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.constant.RefreshState;
import com.scwang.smartrefresh.layout.listener.OnLoadMoreListener;
import com.scwang.smartrefresh.layout.listener.OnRefreshListener;
import com.tencent.mm.opensdk.modelmsg.SendMessageToWX;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;

@SuppressLint("ValidFragment")
public class GroupShopFragment extends LoadingFragment implements OnRefreshListener, OnLoadMoreListener {

    public Context mContext;
    Unbinder unbinder;
    @BindView(R.id.rvView)
    RecyclerView rv;
    @BindView(R.id.llNone)
    LinearLayout llNone;
    @BindView(R.id.logscl)
    ConsecutiveScrollerLayout logscl;
    @BindView(R.id.logNoneTv)
    TextView logNoneTv;
    private ShopAdapter adapter;
    private List<ShopEntity> list = new ArrayList<>();
    private int currentPage = 1;
    private String pageSize = "20";
    private boolean isEnd = false;//是否到底
    private BottomListsDialog bottomListsDialog = null;
    private BottomListsDialog bottomListsDialog2 = null;
    private List<String> dialogList = new ArrayList<>();
    private List<String> dialogList2 = new ArrayList<>();
    private static int SOURSE = 9;//选员工所用标识
    private Bitmap bitmapImgLogo = null;//分享所用
    private Bitmap bitmapImgShop = null;//分享所用
    private String receiverGoodsCode = "";//交接物品所用
    private String groupCode="",groupName="";

    public GroupShopFragment() {
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mContext = getActivity();
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_log, container, false);
        unbinder = ButterKnife.bind(this, view);
        return view;
    }


    @Override
    public void initData() {
        logNoneTv.setText("暂无物品");
        logscl.setBackgroundColor(mContext.getResources().getColor(R.color.main_bg));
        rv.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false));
        adapter = new ShopAdapter(R.layout.item_shop, getActivity(), list);
        ((SimpleItemAnimator) rv.getItemAnimator()).setSupportsChangeAnimations(false);
        rv.setAdapter(adapter);
        dialogList.add("分享");
        dialogList.add("物品交接");
        dialogList.add("申请遗失");
        dialogList.add("申请报废");
        dialogList.add("申请维修");
        dialogList.add("维修记录");
        dialogList.add("项目交付");
        dialogList.add("取消");
        dialogList2.add("分享");
        dialogList2.add("物品交接");
        dialogList2.add("项目交付");
        dialogList2.add("取消");
        String picUrl = new ShareUtils().getString(mContext, StaticClass.COMPANYLOGO, "");
        try {
            Glide.with(this).asBitmap()
                    .diskCacheStrategy(DiskCacheStrategy.AUTOMATIC).load(picUrl)
                    .into(new SimpleTarget<Bitmap>() {
                        @Override
                        public void onResourceReady(@androidx.annotation.NonNull Bitmap resource, @androidx.annotation.Nullable Transition<? super Bitmap> transition) {
                            try {
                                if (resource != null) {
                                    bitmapImgLogo = resource;
                                }
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        }
                    });
        } catch (Exception e) {
            e.printStackTrace();
        }
        getData();
    }

    private RefreshLayout refreshLayout;

    public void setGroupCode(String code,String name) {
        groupCode=code;
        groupName=name;
    }

    @Override
    public void onRefresh(@androidx.annotation.NonNull final RefreshLayout refreshLayout) {
        this.refreshLayout = refreshLayout;
        isEnd = false;
        currentPage = 1;
        getData();
    }

    @Override
    public void onLoadMore(@androidx.annotation.NonNull final RefreshLayout refreshLayout) {
        this.refreshLayout = refreshLayout;
        if (isEnd) {//has next page
            MyToast.show("没有更多数据了");
            loadEnd();
        } else {
            currentPage++;
            getData();
        }
    }

    private void getData() {
        Map<String, String> map = new HashMap<>();
        map.put("pageNum", currentPage + "");
        map.put("pageSize", pageSize + "");
        map.put("groupCode", groupCode);
        MyHttpRequest.getDefault().postRequest(new TypeToken<LzyResponse<List<ShopEntity>>>() {
        }.getType(), null, Urls.selectGoodsPageList, SignUtils2.makeSignStr(map), false, new ObserverCallback<List<ShopEntity>>() {
            @Override
            public void onSuccess(List<ShopEntity> data) {
                if (currentPage == 1) {
                    list.clear();
                    adapter.notifyDataSetChanged();
                }
                if (rv == null || llNone == null) {
                    return;
                }
                int oldIndex = list.size();
                if (data != null && data.size() > 0) {
                    list.addAll(data);
                    adapter.notifyItemRangeChanged(oldIndex, data.size());
                    rv.setVisibility(View.VISIBLE);
                    llNone.setVisibility(View.GONE);
                } else {
                    isEnd = true;
                    if (list.size() == 0) {
                        rv.setVisibility(View.GONE);
                        llNone.setVisibility(View.VISIBLE);
                    }
                }
                loadEnd();

            }

            @Override
            public void onError(String errorMsg) {
                loadEnd();
                MyToast.show(Utils.onErrorTips(errorMsg));
            }
        });
    }


    private void loadEnd() {
        if (null != refreshLayout && refreshLayout.getState() == RefreshState.Refreshing)
            refreshLayout.finishRefresh(true);
        if (null != refreshLayout && refreshLayout.getState() == RefreshState.Loading)
            refreshLayout.finishLoadMore(true);
    }


    class ShopAdapter extends BaseQuickAdapter<ShopEntity, BaseViewHolderEx> {
        private Activity context;

        public ShopAdapter(int layoutResId, Activity context, @io.reactivex.annotations.Nullable List<ShopEntity> data) {
            super(layoutResId, data);
            this.context = context;
        }

        @Override
        protected void convert(BaseViewHolderEx helper, ShopEntity entity) {
            RelativeLayout rlType = helper.getView(R.id.rlType);
            TextView tvTitle = helper.getView(R.id.tvTitle);
            TextView tvType = helper.getView(R.id.tvType);
            TextView tvInit = helper.getView(R.id.tvInit);
            RoundCornerImageView ivImg = helper.getView(R.id.ivImg);
            LinearLayout llMore = helper.getView(R.id.llMore);
            LinearLayout llBg = helper.getView(R.id.llBg);
            llBg.setBackgroundColor(mContext.getResources().getColor(R.color.white));
            View line = helper.getView(R.id.line);
            if(helper.getItemPosition()==0){
                line.setVisibility(View.GONE);
            }else{
                line.setVisibility(View.VISIBLE);
            }
            String title = entity.getGoodsName() + " <font color='#999999'>" + entity.getGoodsCode() + "</font> " + ClearMoreZeroUtil.subZeroAndDot(entity.getAmt()) + "元";

            tvInit.setText("所属人:" + entity.getOwnerEmployeeName() + "   所属项目组:" + entity.getGroupName());
            GlideUtils.load(context, entity.getImageUrl(), ivImg, R.drawable.default_news);
            //auditCd0待审批 1通过 2不通过3废弃
            //statusCd 1-正常 2-遗失 3-报废 4-删除 5-遗失申请中 6-报废申请中7-交付中 8-维修中）
            //receiverCd 1-交接中 0-没有
            RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) tvType.getLayoutParams();
            params.height = Utils.dip2px(context, 14);
            if (entity.getCacheStatus() == 2) {
                title = entity.getGoodsName() + " " + ClearMoreZeroUtil.subZeroAndDot(entity.getAmt()) + "元";
                params.width = Utils.dip2px(context, 45);
                tvType.setLayoutParams(params);
                tvType.setText("上传失败");
                tvType.setBackgroundResource(R.drawable.shop_f2434d_bg);
            } else {
                params.width = Utils.dip2px(context, 40);
                tvType.setLayoutParams(params);
                title = entity.getGoodsName() + " <font color='#999999'>" + entity.getGoodsCode() + "</font> " + ClearMoreZeroUtil.subZeroAndDot(entity.getAmt()) + "元";
                if ("0".equals(entity.getAuditCd())) {
                    tvType.setText("审核中");
                    tvType.setBackgroundResource(R.drawable.shop_fca817_bg);
                } else if ("1".equals(entity.getAuditCd())) {
                    if ("1".equals(entity.getReceiverCd())) {
                        tvType.setText("交接中");
                        tvType.setBackgroundResource(R.drawable.shop_fca817_bg);
                    } else {
                        if ("5".equals(entity.getStatusCd())) {
                            tvType.setText("遗失中");
                            tvType.setBackgroundResource(R.drawable.shop_f2434d_bg);
                        } else if ("6".equals(entity.getStatusCd())) {
                            tvType.setText("报废中");
                            tvType.setBackgroundResource(R.drawable.shop_9a9a9a_bg);
                        } else if ("7".equals(entity.getStatusCd())) {
                            tvType.setText("交付中");
                            tvType.setBackgroundResource(R.drawable.shop_9a9a9a_bg);
                        } else if ("8".equals(entity.getStatusCd())) {
                            tvType.setText("维修中");
                            tvType.setBackgroundResource(R.drawable.shop_9a9a9a_bg);
                        } else if ("2".equals(entity.getStatusCd())) {
                            tvType.setText("遗失");
                            tvType.setBackgroundResource(R.drawable.shop_f2434d_bg);
                        } else if ("3".equals(entity.getStatusCd())) {
                            tvType.setText("报废");
                            tvType.setBackgroundResource(R.drawable.shop_9a9a9a_bg);
                        } else {
                            tvType.setText("正常");
                            tvType.setBackgroundResource(R.drawable.shop_00c993_bg);
                        }
                    }
                } else if ("3".equals(entity.getAuditCd())) {
                    tvType.setText("废弃");
                    tvType.setBackgroundResource(R.drawable.shop_9a9a9a_bg);
                } else {
                    //不通过 实际应该不存在
                    tvType.setText("不通过");
                    tvType.setBackgroundResource(R.drawable.shop_f2434d_bg);
                }
            }
            tvTitle.setText(Html.fromHtml(title));
            llMore.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (entity.getBaoixaoTypeCode().equals("BAOX202001010001")) {
                        //房屋租赁
                        showDialog(entity,2);
                    } else {
                        showDialog(entity,0);
                    }
                }
            });
            helper.getItemView().setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (Urls.antiShake.check()) {
                        return;
                    }
                    Intent intent = new Intent(context, ShopDetailActivity.class);
                    intent.putExtra("goodsCode", entity.getGoodsCode());
                    intent.putExtra("type", entity);
                    if (entity.getStatusCd().equals("7")) {
                        intent.putExtra("projectDelivery", true);
                    }
                    context.startActivity(intent);
                }
            });
        }
    }
private void showDialog(ShopEntity entity,int type){
        if(type==0){
            bottomListsDialog = new BottomListsDialog(mContext, dialogList, new SelectDialogListener() {
                @Override
                public void onCancel() {

                }

                @Override
                public void onListItemClick(int position, List<String> list) {

                    if ("0".equals(entity.getAuditCd())) {
                        MyToast.show("该物品未通过审核");
                    } else if ("1".equals(entity.getAuditCd())) {
                        if ("1".equals(entity.getReceiverCd())) {
                            MyToast.show("该物品正在交接中");
                        } else {
                            if ("5".equals(entity.getStatusCd())) {
                                MyToast.show("该物品遗失申请中，暂停其他操作");
                            } else if ("6".equals(entity.getStatusCd())) {
                                MyToast.show("该物品报废申请中，暂停其他操作");
                            } else if ("7".equals(entity.getStatusCd())) {
                                MyToast.show("该物品交付申请中，暂停其他操作");
                            } else if ("8".equals(entity.getStatusCd())) {
                                if (position == 5) {
                                    Intent intent = new Intent(mContext, ShopServiceRecordActivity.class);
                                    intent.putExtra("goodsCode", entity.getGoodsCode());
                                    startActivity(intent);
                                } else {
                                    MyToast.show("该物品维修申请中，暂停其他操作");
                                }
                            } else if ("2".equals(entity.getStatusCd())) {
                                MyToast.show("该物品已遗失");
                            } else if ("3".equals(entity.getStatusCd())) {
                                MyToast.show("该物品已报废");
                            } else {
                                if (position == 0) {
                                    String url = Urls.shopShare + "goodsCode=" + entity.getGoodsCode() + "&companyCode=" + new ShareUtils().getString(mContext, StaticClass.COMPANYCODE, "");
                                    if (Utils.isNull(entity.getImageUrl())) {
                                        bitmapImgShop = bitmapImgLogo;
                                        WeChatShareUtil.getInstance(mContext).shareUrl(url, entity.getOwnerEmployeeName() + "的" + entity.getGoodsName(), bitmapImgShop, "让学习和分享成为工作的一部分", SendMessageToWX.Req.WXSceneSession);
                                    } else {
                                        try {
                                            Glide.with(mContext).asBitmap()
                                                    .diskCacheStrategy(DiskCacheStrategy.AUTOMATIC).load(entity.getImageUrl())
                                                    .into(new SimpleTarget<Bitmap>() {
                                                        @Override
                                                        public void onResourceReady(@androidx.annotation.NonNull Bitmap resource, @androidx.annotation.Nullable Transition<? super Bitmap> transition) {
                                                            try {
                                                                if (resource != null) {
                                                                    bitmapImgShop = resource;
                                                                } else {
                                                                    if (bitmapImgLogo != null) {
                                                                        bitmapImgShop = bitmapImgLogo;
                                                                    } else {
                                                                        bitmapImgShop = BitmapFactory.decodeResource(getResources(),  GlideUtils.loadPushId(mContext));
                                                                    }
                                                                }
                                                                WeChatShareUtil.getInstance(mContext).shareUrl(url, entity.getOwnerEmployeeName() + "的" + entity.getGoodsName(), bitmapImgShop, "让学习和分享成为工作的一部分", SendMessageToWX.Req.WXSceneSession);
                                                            } catch (Exception e) {
                                                                e.printStackTrace();
                                                            }
                                                        }
                                                    });
                                        } catch (Exception e) {
                                            e.printStackTrace();
                                        }
                                    }
                                } else if (position == 1) {
                                    receiverGoodsCode = entity.getGoodsCode();
                                    MyApp.contactEntityLogList.clear();
                                    Intent intent = new Intent(mContext, ContactsLogChoiceActivity.class);
                                    intent.putExtra("source", SOURSE + "");
                                    startActivity(intent);
                                } else if (position == 2 || position == 3) {
                                    Intent intent = new Intent(mContext, ShopStatusEditActivity.class);
                                    intent.putExtra("type", position);
                                    intent.putExtra("goodsCode", entity.getGoodsCode());
                                    startActivity(intent);
                                } else if (position == 4) {
                                    Intent intent = new Intent(mContext, ShopServiceActivity.class);
                                    intent.putExtra("goodsCode", entity.getGoodsCode());
                                    intent.putExtra("goodsName", entity.getGoodsName());
                                    intent.putExtra("baoixaoTypeCode", entity.getBaoixaoTypeCode());
                                    intent.putExtra("baoixaoTypeName", entity.getBaoixaoTypeName());
                                    startActivity(intent);
                                } else if (position == 5) {
                                    Intent intent = new Intent(mContext, ShopServiceRecordActivity.class);
                                    intent.putExtra("goodsCode", entity.getGoodsCode());
                                    startActivity(intent);
                                } else if (position == 6) {
                                    Intent intent = new Intent(mContext, ShopProjecDeliveryActivity.class);
                                    intent.putExtra("goodsCode", entity.getGoodsCode());
                                    startActivity(intent);
                                }

                            }
                        }
                    } else if ("3".equals(entity.getAuditCd())) {
                        MyToast.show("该物品已废弃");
                    } else {
                        //不通过 实际应该不存在
                        MyToast.show("该物品未通过审核");
                    }

                    bottomListsDialog.dismiss();
                }
            });
            bottomListsDialog.show();
        }else{
            bottomListsDialog2 = new BottomListsDialog(mContext, dialogList2, new SelectDialogListener() {
                @Override
                public void onCancel() {

                }

                @Override
                public void onListItemClick(int position, List<String> list) {

                    if ("0".equals(entity.getAuditCd())) {
                        MyToast.show("该物品未通过审核");
                    } else if ("1".equals(entity.getAuditCd())) {
                        if ("1".equals(entity.getReceiverCd())) {
                            MyToast.show("该物品正在交接中");
                        } else {
                            if ("5".equals(entity.getStatusCd())) {
                                MyToast.show("该物品遗失申请中，暂停其他操作");
                            } else if ("6".equals(entity.getStatusCd())) {
                                MyToast.show("该物品报废申请中，暂停其他操作");
                            } else if ("7".equals(entity.getStatusCd())) {
                                MyToast.show("该物品交付申请中，暂停其他操作");
                            } else if ("8".equals(entity.getStatusCd())) {
                                if (position == 5) {
                                    Intent intent = new Intent(mContext, ShopServiceRecordActivity.class);
                                    intent.putExtra("goodsCode", entity.getGoodsCode());
                                    startActivity(intent);
                                } else {
                                    MyToast.show("该物品维修申请中，暂停其他操作");
                                }
                            } else if ("2".equals(entity.getStatusCd())) {
                                MyToast.show("该物品已遗失");
                            } else if ("3".equals(entity.getStatusCd())) {
                                MyToast.show("该物品已报废");
                            } else {
                                if (position == 0) {
                                    String url = Urls.shopShare + "goodsCode=" + entity.getGoodsCode() + "&companyCode=" + new ShareUtils().getString(mContext, StaticClass.COMPANYCODE, "");
                                    if (Utils.isNull(entity.getImageUrl())) {
                                        bitmapImgShop = bitmapImgLogo;
                                        WeChatShareUtil.getInstance(mContext).shareUrl(url, entity.getOwnerEmployeeName() + "的" + entity.getGoodsName(), bitmapImgShop, "让学习和分享成为工作的一部分", SendMessageToWX.Req.WXSceneSession);
                                    } else {
                                        try {
                                            Glide.with(mContext).asBitmap()
                                                    .diskCacheStrategy(DiskCacheStrategy.AUTOMATIC).load(entity.getImageUrl())
                                                    .into(new SimpleTarget<Bitmap>() {
                                                        @Override
                                                        public void onResourceReady(@androidx.annotation.NonNull Bitmap resource, @androidx.annotation.Nullable Transition<? super Bitmap> transition) {
                                                            try {
                                                                if (resource != null) {
                                                                    bitmapImgShop = resource;
                                                                } else {
                                                                    if (bitmapImgLogo != null) {
                                                                        bitmapImgShop = bitmapImgLogo;
                                                                    } else {
                                                                        bitmapImgShop = BitmapFactory.decodeResource(getResources(),  GlideUtils.loadPushId(mContext));
                                                                    }
                                                                }
                                                                WeChatShareUtil.getInstance(mContext).shareUrl(url, entity.getOwnerEmployeeName() + "的" + entity.getGoodsName(), bitmapImgShop, "让学习和分享成为工作的一部分", SendMessageToWX.Req.WXSceneSession);
                                                            } catch (Exception e) {
                                                                e.printStackTrace();
                                                            }
                                                        }
                                                    });
                                        } catch (Exception e) {
                                            e.printStackTrace();
                                        }
                                    }
                                } else if (position == 1) {
                                    receiverGoodsCode = entity.getGoodsCode();
                                    MyApp.contactEntityLogList.clear();
                                    Intent intent = new Intent(mContext, ContactsLogChoiceActivity.class);
                                    intent.putExtra("source", SOURSE + "");
                                    startActivity(intent);
                                } else if (position == 2) {
                                    Intent intent = new Intent(mContext, ShopProjecDeliveryActivity.class);
                                    intent.putExtra("goodsCode", entity.getGoodsCode());
                                    startActivity(intent);
                                }

                            }
                        }
                    } else if ("3".equals(entity.getAuditCd())) {
                        MyToast.show("该物品已废弃");
                    } else {
                        //不通过 实际应该不存在
                        MyToast.show("该物品未通过审核");
                    }

                    bottomListsDialog2.dismiss();
                }
            });
            bottomListsDialog2.show();

        }
}
    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onMoonEvent(MyEvent messageEvent) {
        //事件订阅者处理事件
        if (messageEvent.getHashMap() != null) {
            Map<String, String> map = messageEvent.getHashMap();
        } else {
            String msg = messageEvent.getMessage();
            if (Utils.isNull(msg)) {
                return;
            }
            if (msg.equals("RefreshShopRecord")||msg.equals("RefreshAudit")) {
                isEnd = false;
                currentPage = 1;
                getData();
            }else if (msg.equals("CloseContacts")) {
                //选择提供者
                if (MyApp.contactEntityLogList.size() > 0) {
                    ContactEntity contactEntity = MyApp.contactEntityLogList.get(0);
                    MyApp.contactEntityLogList.clear();
                    receiverGoods(contactEntity.getEmployeeCode(), contactEntity.getEmployeeName());
                }
            }
        }
    }

    private void receiverGoods(String receiverEmployeeCode, String receiverEmployeeName) {
        Map<String, String> map = new HashMap<>();
        map.put("goodsCode", receiverGoodsCode);
        map.put("receiverCd", "1");//如果是选择交接人对外交接 这个值传1 如果是接收传0、拒收物品 这个值传2
        map.put("receiverEmployeeName", receiverEmployeeName);
        map.put("receiverEmployeeCode", receiverEmployeeCode);
        showLoading();
        MyHttpRequest.postRequest(Urls.receiverGoods, this, SignUtils2.makeSignStr(map), new JsonCallback<String>() {
            @Override
            public void onSuccess(Response<String> response) {
                try {
                    dismissLoading();
                    JSONObject jsonObject = new JSONObject(response.body().toString());
                    if ("200".equals(jsonObject.getString("code"))) {
                        MyToast.show("提交成功");
                        isEnd = false;
                        currentPage = 1;
                        getData();
                    } else {
                        if (jsonObject.getString("code").startsWith("400")) {
                            OkGoUtil.onErrorIntent(jsonObject.getString("code"), jsonObject.getString("msg"));
                        } else {
                            MyToast.show(jsonObject.getString("msg"));
                        }
                    }

                } catch (JSONException e) {
                    e.printStackTrace();
                    dismissLoading();
                    MyToast.show("提交失败，请稍后重试");
                }
            }
        });
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        EventBus.getDefault().unregister(this);
        unbinder.unbind();

    }

}
